package com.usian.wemedia.controller;

import com.usian.apis.wemedia.WmUserControllerApi;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.media.pojos.WmUser;
import com.usian.wemedia.service.WmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/user")
public class WmUserController implements WmUserControllerApi {
    @Autowired
    private WmUserService wmUserService;
    //保存自媒体用户信息
    @Override
    @PostMapping("/save")
    public ResponseResult save(@RequestBody  WmUser wmUser) {
        return wmUserService.saveWmUser(wmUser);
    }
    //根据用户名称查询用户
    @Override
    @GetMapping("/findByName/{name}")
    public WmUser findByName(@PathVariable String name) {
        return wmUserService.findByName(name);
    }

    @Override
    @GetMapping("/findByUserId/{userId}")
    public WmUser findByUserId(@PathVariable Long userId) {
        WmUser byId = wmUserService.getById(userId);
        return byId;
    }
}
